package borge.web.teamspirit.client.data;

import java.io.Serializable;
import java.util.HashMap;

import borge.web.teamspirit.client.interfaces.PersistentData;

// PersistentData because we send it over general rpc channels..
public class SerieStats implements PersistentData {

	private HashMap<String, SeriePlayerStats> iPlayerStatsMap;
	
	public String iSerieKey;
	
	public int iMatchesWon;
	public int iMatchesLost;
	public int iMatchesDraw;
	
	public int iGoalsMade;
	public int iOppGoals;
	public int iYellowCards;
	public int iRedCards;
	
	public static class SeriePlayerStats implements Serializable{
		
		public SeriePlayerStats(){
			
		}
		
		public int iGoals;
		public int iAssists;
		public int iRedCards;
		public int iYellowCards;
		
	}

	public SerieStats(){
	
		iPlayerStatsMap = new HashMap<String, SeriePlayerStats>();
	}
	
	public void addPlayerStats(String aPlayerKey, int aGoals, int aAssists, 
			boolean aRedCards, boolean aYellowCards){
		
		SeriePlayerStats stats = iPlayerStatsMap.get(aPlayerKey);
		if(stats == null){
			stats = new SeriePlayerStats();
			iPlayerStatsMap.put(aPlayerKey, stats);
		}
		
		stats.iGoals += aGoals;
		stats.iAssists += aAssists;
		if(aRedCards)
			stats.iRedCards++;
		if(aYellowCards)
			stats.iYellowCards++;
	}
	
	public SeriePlayerStats getSeriePlayerStats(String aPlayerKey){
		return iPlayerStatsMap.get(aPlayerKey);
	}

	@Override
	public String getDisplayingWidget() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getEncodedKey() {
		// TODO Auto-generated method stub
		return null;
	}
}
